package sphere.view;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;

import sphere.controller.SphereController;
 

public class SphereWindow extends Frame {

	private Panel p;
	private static final String stringRayon=new String("Rayon : ");
	private static final String stringVolume=new String("Volume : ");
	private static final String stringSurface=new String("Surface : ");
	
	private TextField textRayon, textVolume, textSurface;
	
	public SphereWindow(String title) {
		super(title);
		this.setLayout(new FlowLayout());
		addWindowListener(new Fermer());
		this.p=new Panel();
		this.add(this.p);
		
		this.p.setLayout(new GridLayout(0,2,10,10));
		
		Label labelRayon=new Label(stringRayon);
		this.textRayon=new TextField();
		p.add(labelRayon);
		p.add(this.textRayon);
		
		
		Label labelVolume=new Label(stringVolume);
		this.textVolume=new TextField();
		this.textVolume.setEnabled(false);
		p.add(labelVolume);
		p.add(this.textVolume);
		
		
		Label labelSurface=new Label(stringSurface);
		this.textSurface=new TextField();
		this.textSurface.setEnabled(false);
		p.add(labelSurface);
		p.add(this.textSurface);
		
		this.pack();
		this.add(p);
		this.setVisible(true);
		
		SphereController ecoute = new SphereController(this);
		this.textRayon.addTextListener(ecoute);
		
	}
	
	public void setSurface(double surface) {
		this.textSurface.setText(String.valueOf(surface));
	}
	
	public void setVolume(double volume) {
		this.textVolume.setText(String.valueOf(volume));
	}

}
